var app = angular.module('menuApp', []);

app.controller('menuController', function($scope, $http) {
	$scope.view=function(){
		$http.get(timestamp("sys/menus/get/"+getQueryString("id"))).success(function (response) {
			$scope.menu = response.data;
			$http.get('sys/menus/getAll/').success(function(response){
				$scope.menuList=response.data;
				$("#sysMenuPid").select2({
					 placeholder: "请选择上级菜单",
					 allowClear: true
				});
	        });
		});
	}
	
	$scope.view();$scope.view();
	$scope.refreshData=function(){
		$scope.view();
	}
	
	$scope.menuSave=function(){
	   if($("#myForm").valid()){
		   $http.put('sys/menus/modify/', $scope.menu).success(function(){
			   redirectUrl("manage/menu/","list.jsp");
           });
	   }
	}
	
	$scope.menuReset=function(){
		$scope.view();
	}
	
	$scope.menuCancle=function(){
		 redirectUrl("manage/menu/","list.jsp");
	}
});